<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title><tiles:insertAttribute name="title" ignore="true" /></title>
</head>
<body>
	<form id="excelUploadForm" method="post" enctype="multipart/form-data">
		<table id="search_option1" width="100%" border="0" radius="3" rborder="#A3CCDD" rbgcolor="#F3F8FA" class="design_table">
        	<tr>
            	<td width="500px">
                	<div style="border: 1px #A3CBDD solid; width:200px; height: 18px; float: left;">
                    	<input type="text" id="fakeUploadTpurse" name="fakeUploadTpurse" readonly="readonly" style="border: 0px; width: 198px; height: 15px;"/>                            		
                    </div>
					<input type="file" id="uploadTpurse" name="uploadTpurse" style="opacity: 0; left: 205px; top: 10px; width: 100px; height: 22px; position: absolute; cursor: pointer; filter: alpha(opacity=0); -ms-filter: alpha(opacity=0); -khtml-opacity: 0; -moz-opacity: 0;"/>
					<input type="button" id="fakeUploadTpurseBtn" value="파일첨부" style="width: 95px; height: 20px;"/>
					<br/><br/>
					<input type="file" style="border: 0px; width: 198px; height: 15px;" />
                </td>
            </tr>
			<tr>
				<td colspan="2">
					<div id="fileSizeArea">파일사이즈 : <span id="fileSize">0</span> Byte</div>
				</td>
			</tr>
        </table>
	</form>


	<!-- /login-extra -->
	<script src="<c:url value='/js/plugin/jquery-1.7.2.min.js'/>"></script>
<%-- 	<script src="<c:url value='/js/plugin/jquery.form.js'/>"></script> --%>
	<script type="text/javascript">
	$(document).ready(function(){
		initEvent();
	});
	function initEvent(){        
        $("#uploadTpurse").change(function() {
        	var fileName = $("#uploadTpurse").val();
        	var splitFileName = fileName.split("\\");
        	$("#fakeUploadTpurse").val(splitFileName[splitFileName.length-1]);
        	
        	$("#excelUploadForm").attr("action", "excelUploadTest.file").submit();
        });
        
        $("#excelUploadForm").ajaxForm( {
        	iframe: "true",
        	type: "POST",
        	dataType: "text",
        	cache: false,
        	modal: true,
        	async : false,
        	success: function (response)
        	{
        		var data = JSON.parse(response);
        		var size = data.file[0].sizeB;
        		$("#fileSize").html(size);
//         		$("#page1Grid").jqGrid('clearGridData').jqGrid('setGridParam', { data: data.excel[0], datatype: 'local' }).trigger('reloadGrid');
// 				$("#btnUpload").removeAttr("disabled");

        	}
       	} );


	}
	</script>
</body>
</html>